package ink.metoo.gude.model

import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.jupiter.api.Test
import java.text.SimpleDateFormat
import java.util.Date

class ApiStatusTest {

    @Test
    fun generateJsonSchema() {
        val mapper = ObjectMapper()
        val dataFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
        val maps = ApiStatus.entries.map {
            mapOf(
                "value" to it.code,
                "name" to it.name,
                "description" to it.message
            )
        }
        val json = mapper.writeValueAsString(
            mapOf(
                "type" to "integer",
                "title" to ApiStatus::class.simpleName,
                "description" to "${dataFormat.format(Date())} 生成",
                "enum" to maps.map { it["value"] },
                "x-apifox-enum" to maps
            )
        )
        println(json)
    }

}